﻿using System.Drawing;

namespace XYAC.Framework.MonitorTireMaterialOnline.DataExporter
{
    /// <summary>
    /// 表示测量类，继承自 BaseProfile 类，负责处理测量数据和关键点的逻辑。
    /// </summary>
    public class Measuring : BaseProfile
    {
        /// <summary>
        /// 关键点列表。
        /// </summary>
        protected PointDataList m_KeyPoints;

        /// <summary>
        /// X轴间隔。
        /// </summary>
        private float m_XInterval;

        /// <summary>
        /// 初始化 Measuring 类的新实例。
        /// </summary>
        /// <param name="MeasurData">测量数据列表。</param>
        /// <param name="XInterval">X轴间隔。</param>
        public Measuring(List<MeasurData> MeasurData, float XInterval)
        {
            if (MeasurData.Count >= 1)
            {
                int num2;
                float bottomHeight = MeasurData[0].BottomHeight;
                m_XInterval = XInterval;

                // 找到最小的底部高度
                for (num2 = 0; num2 < MeasurData.Count; num2++)
                {
                    if (MeasurData[num2].BottomHeight < bottomHeight)
                    {
                        bottomHeight = MeasurData[num2].BottomHeight;
                    }
                }

                // 初始化底部高度点和厚度点
                base.m_BottomHeightPoints = new PointDataList();
                for (num2 = 0; num2 < MeasurData.Count; num2++)
                {
                    base.m_ThicknessPoints.Add(new PointData(new PointF(num2 * XInterval, MeasurData[num2].Thickness)));
                    base.m_BottomHeightPoints.Add(new PointData(new PointF(num2 * XInterval, MeasurData[num2].BottomHeight - bottomHeight)));
                }
                base.m_Size = base.ThicknessPoints.Size;
                m_KeyPoints = new PointDataList();
            }
        }

        /// <summary>
        /// 获取或设置关键点列表，并按X轴排序。
        /// </summary>
        public PointDataList KeyPoints
        {
            get
            {
                m_KeyPoints.AscSortForX();
                return m_KeyPoints;
            }
            set
            {
                m_KeyPoints = value;
            }
        }

        /// <summary>
        /// 获取X轴间隔。
        /// </summary>
        public float XInterval
        {
            get
            {
                return m_XInterval;
            }
        }

        /// <summary>
        /// 获取或设置X轴参考值。
        /// </summary>
        public override float XReference
        {
            get
            {
                return base.m_XReference;
            }
            set
            {
                base.m_XReference = value;
            }
        }

        /// <summary>
        /// 表示测量数据的嵌套类。
        /// </summary>
        public class MeasurData
        {
            /// <summary>
            /// 底部高度。
            /// </summary>
            private float m_BottomHeight;

            /// <summary>
            /// 厚度。
            /// </summary>
            private float m_Thickness;

            /// <summary>
            /// 初始化 MeasurData 类的新实例。
            /// </summary>
            /// <param name="Thickness">厚度。</param>
            /// <param name="BottomHeight">底部高度。</param>
            public MeasurData(float Thickness, float BottomHeight)
            {
                m_Thickness = Thickness;
                m_BottomHeight = BottomHeight;
            }

            /// <summary>
            /// 获取底部高度。
            /// </summary>
            public float BottomHeight
            {
                get
                {
                    return m_BottomHeight;
                }
            }

            /// <summary>
            /// 获取或设置厚度。
            /// </summary>
            public float Thickness
            {
                get
                {
                    return m_Thickness;
                }
                set
                {
                    m_Thickness = value;
                }
            }
        }
    }

}
